<?php
namespace app\admin\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username'  =>  'require|length:4,18',
        'password' =>  'require|length:6,18',
    ];

    protected $message = [
        'username.require' => '用户名不为空',
        'username.length' => '用户名格式错误',
        'password.require' => '密码不为空',
        'password.length' => '6-18位的数字或字符',
    ];

    // 自定义验证规则
    protected function checkName($value,$rule,$data)
    {
        return $rule == $value ? true : '名称错误';
    }
}